package com.bawei.week3;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import android.os.Build;
import android.os.Bundle;

import com.bawei.week3.adapter.MyFragmentPagerAdapter;
import com.bawei.week3.fragment.ContactsFragment;
import com.bawei.week3.fragment.MessageFragment;
import com.bawei.week3.fragment.MusicFragment;
import com.bawei.week3.fragment.PictureFragment;

import java.util.ArrayList;
import java.util.List;

/***
   内容提供者：获得音乐+视频+联系+短信+图片
   广播：发送普通+有序+粘性
   服务：start+bind+IntentService 下载
 */
public class MainActivity extends AppCompatActivity {
    private ViewPager viewPager;
    private MyFragmentPagerAdapter myFragmentPagerAdapter;
    private List<Fragment> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.M) {
            requestPermissions(new String[]{
                    "android.permission.INTERNET",
                    "android.permission.WRITE_EXTERNAL_STORAGE",
                    "android.permission.READ_EXTERNAL_STORAGE",
                    "android.permission.READ_CONTACTS",
                    "android.permission.READ_SMS",
                    "android.permission.CALL_PHONE",
                    "android.permission.READ_CALL_LOG",
                    "android.permission.WRITE_CALL_LOG",
                    "android.permission.ACCESS_NETWORK_STATE",
                    "android.permission.READ_PHONE_STATE"

            }, 101);

        }
        viewPager = findViewById(R.id.view_pager);
        list = new ArrayList<>();
        list.add(new MusicFragment());
        list.add(new PictureFragment());
        list.add(new ContactsFragment());
        list.add(new MessageFragment());
        myFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(),list);
        viewPager.setAdapter(myFragmentPagerAdapter);
    }
}
